﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using PAT.Entities;
using PAT.Data;

#endregion

namespace PAT.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="PatTransferenciaProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class PatTransferenciaProviderBaseCore : EntityProviderBase<PAT.Entities.PatTransferencia, PAT.Entities.PatTransferenciaKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia
		
		/// <summary>
		///		Gets PAT_TRANSFERENCIA objects from the datasource by ID_DOCUMENTO_ORDEN in the
		///		PAT_ORDEN_TRABAJO_TRANSFERENCIA table. Table PAT_TRANSFERENCIA is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_TRANSFERENCIA table.
		/// </summary>
		/// <param name="_idDocumentoOrden"></param>
		/// <param name="_numeroOrden"></param>
		/// <returns>Returns a typed collection of PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(System.Int32 _idDocumentoOrden, System.Int32 _numeroOrden)
		{
			int count = -1;
			return GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(null,_idDocumentoOrden, _numeroOrden, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatTransferencia objects from the datasource by ID_DOCUMENTO_ORDEN in the
		///		PAT_ORDEN_TRABAJO_TRANSFERENCIA table. Table PAT_TRANSFERENCIA is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_TRANSFERENCIA table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idDocumentoOrden"></param>
		/// <param name="_numeroOrden"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(System.Int32 _idDocumentoOrden, System.Int32 _numeroOrden, int start, int pageLength)
		{
			int count = -1;
			return GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(null, _idDocumentoOrden, _numeroOrden, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatTransferencia objects from the datasource by ID_DOCUMENTO_ORDEN in the
		///		PAT_ORDEN_TRABAJO_TRANSFERENCIA table. Table PAT_TRANSFERENCIA is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_TRANSFERENCIA table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumentoOrden"></param>
		/// <param name="_numeroOrden"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_TRANSFERENCIA objects.</returns>
		public TList<PatTransferencia> GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(TransactionManager transactionManager, System.Int32 _idDocumentoOrden, System.Int32 _numeroOrden)
		{
			int count = -1;
			return GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(transactionManager, _idDocumentoOrden, _numeroOrden, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatTransferencia objects from the datasource by ID_DOCUMENTO_ORDEN in the
		///		PAT_ORDEN_TRABAJO_TRANSFERENCIA table. Table PAT_TRANSFERENCIA is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_TRANSFERENCIA table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumentoOrden"></param>
		/// <param name="_numeroOrden"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_TRANSFERENCIA objects.</returns>
		public TList<PatTransferencia> GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(TransactionManager transactionManager, System.Int32 _idDocumentoOrden, System.Int32 _numeroOrden,int start, int pageLength)
		{
			int count = -1;
			return GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(transactionManager, _idDocumentoOrden, _numeroOrden, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatTransferencia objects from the datasource by ID_DOCUMENTO_ORDEN in the
		///		PAT_ORDEN_TRABAJO_TRANSFERENCIA table. Table PAT_TRANSFERENCIA is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_TRANSFERENCIA table.
		/// </summary>
		/// <param name="_idDocumentoOrden"></param>
		/// <param name="_numeroOrden"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_TRANSFERENCIA objects.</returns>
		public TList<PatTransferencia> GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(System.Int32 _idDocumentoOrden, System.Int32 _numeroOrden,int start, int pageLength, out int count)
		{
			
			return GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(null, _idDocumentoOrden, _numeroOrden, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_TRANSFERENCIA objects from the datasource by ID_DOCUMENTO_ORDEN in the
		///		PAT_ORDEN_TRABAJO_TRANSFERENCIA table. Table PAT_TRANSFERENCIA is related to table PAT_ORDEN_TRABAJO
		///		through the (M:N) relationship defined in the PAT_ORDEN_TRABAJO_TRANSFERENCIA table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idDocumentoOrden"></param>
		/// <param name="_numeroOrden"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatTransferencia objects.</returns>
		public abstract TList<PatTransferencia> GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia(TransactionManager transactionManager,System.Int32 _idDocumentoOrden, System.Int32 _numeroOrden, int start, int pageLength, out int count);
		
		#endregion GetByIdDocumentoOrdenNumeroOrdenFromPatOrdenTrabajoTransferencia
		
		#region GetByIdItemInventarioFromPatTransferenciaDetalle
		
		/// <summary>
		///		Gets PAT_TRANSFERENCIA objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_TRANSFERENCIA_DETALLE table. Table PAT_TRANSFERENCIA is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_TRANSFERENCIA_DETALLE table.
		/// </summary>
		/// <param name="_idItemInventario"></param>
		/// <returns>Returns a typed collection of PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdItemInventarioFromPatTransferenciaDetalle(System.Int32 _idItemInventario)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatTransferenciaDetalle(null,_idItemInventario, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets PAT.Entities.PatTransferencia objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_TRANSFERENCIA_DETALLE table. Table PAT_TRANSFERENCIA is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_TRANSFERENCIA_DETALLE table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdItemInventarioFromPatTransferenciaDetalle(System.Int32 _idItemInventario, int start, int pageLength)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatTransferenciaDetalle(null, _idItemInventario, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatTransferencia objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_TRANSFERENCIA_DETALLE table. Table PAT_TRANSFERENCIA is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_TRANSFERENCIA_DETALLE table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_TRANSFERENCIA objects.</returns>
		public TList<PatTransferencia> GetByIdItemInventarioFromPatTransferenciaDetalle(TransactionManager transactionManager, System.Int32 _idItemInventario)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatTransferenciaDetalle(transactionManager, _idItemInventario, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets PatTransferencia objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_TRANSFERENCIA_DETALLE table. Table PAT_TRANSFERENCIA is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_TRANSFERENCIA_DETALLE table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemInventario"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_TRANSFERENCIA objects.</returns>
		public TList<PatTransferencia> GetByIdItemInventarioFromPatTransferenciaDetalle(TransactionManager transactionManager, System.Int32 _idItemInventario,int start, int pageLength)
		{
			int count = -1;
			return GetByIdItemInventarioFromPatTransferenciaDetalle(transactionManager, _idItemInventario, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets PatTransferencia objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_TRANSFERENCIA_DETALLE table. Table PAT_TRANSFERENCIA is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_TRANSFERENCIA_DETALLE table.
		/// </summary>
		/// <param name="_idItemInventario"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT_TRANSFERENCIA objects.</returns>
		public TList<PatTransferencia> GetByIdItemInventarioFromPatTransferenciaDetalle(System.Int32 _idItemInventario,int start, int pageLength, out int count)
		{
			
			return GetByIdItemInventarioFromPatTransferenciaDetalle(null, _idItemInventario, start, pageLength, out count);
		}


		/// <summary>
		///		Gets PAT_TRANSFERENCIA objects from the datasource by ID_ITEM_INVENTARIO in the
		///		PAT_TRANSFERENCIA_DETALLE table. Table PAT_TRANSFERENCIA is related to table PAT_ITEM_INVENTARIO
		///		through the (M:N) relationship defined in the PAT_TRANSFERENCIA_DETALLE table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_idItemInventario"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of PatTransferencia objects.</returns>
		public abstract TList<PatTransferencia> GetByIdItemInventarioFromPatTransferenciaDetalle(TransactionManager transactionManager,System.Int32 _idItemInventario, int start, int pageLength, out int count);
		
		#endregion GetByIdItemInventarioFromPatTransferenciaDetalle
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, PAT.Entities.PatTransferenciaKey key)
		{
			return Delete(transactionManager, key.IdDocumento, key.NumeroTransferencia);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_idDocumento">. Primary Key.</param>
		/// <param name="_numeroTransferencia">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _idDocumento, System.Int32 _numeroTransferencia)
		{
			return Delete(null, _idDocumento, _numeroTransferencia);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento">. Primary Key.</param>
		/// <param name="_numeroTransferencia">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _idDocumento, System.Int32 _numeroTransferencia);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN key.
		///		FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN Description: 
		/// </summary>
		/// <param name="_idCargoTransferencia"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdCargoTransferencia(System.Byte _idCargoTransferencia)
		{
			int count = -1;
			return GetByIdCargoTransferencia(_idCargoTransferencia, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN key.
		///		FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idCargoTransferencia"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		/// <remarks></remarks>
		public TList<PatTransferencia> GetByIdCargoTransferencia(TransactionManager transactionManager, System.Byte _idCargoTransferencia)
		{
			int count = -1;
			return GetByIdCargoTransferencia(transactionManager, _idCargoTransferencia, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN key.
		///		FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idCargoTransferencia"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdCargoTransferencia(TransactionManager transactionManager, System.Byte _idCargoTransferencia, int start, int pageLength)
		{
			int count = -1;
			return GetByIdCargoTransferencia(transactionManager, _idCargoTransferencia, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN key.
		///		fkPatTransferenciaPatCargoOrden Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idCargoTransferencia"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdCargoTransferencia(System.Byte _idCargoTransferencia, int start, int pageLength)
		{
			int count =  -1;
			return GetByIdCargoTransferencia(null, _idCargoTransferencia, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN key.
		///		fkPatTransferenciaPatCargoOrden Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idCargoTransferencia"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdCargoTransferencia(System.Byte _idCargoTransferencia, int start, int pageLength,out int count)
		{
			return GetByIdCargoTransferencia(null, _idCargoTransferencia, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN key.
		///		FK_PAT_TRANSFERENCIA_PAT_CARGO_ORDEN Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idCargoTransferencia"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public abstract TList<PatTransferencia> GetByIdCargoTransferencia(TransactionManager transactionManager, System.Byte _idCargoTransferencia, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO key.
		///		FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO Description: 
		/// </summary>
		/// <param name="_idDocumento"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdDocumento(System.Int32 _idDocumento)
		{
			int count = -1;
			return GetByIdDocumento(_idDocumento, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO key.
		///		FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		/// <remarks></remarks>
		public TList<PatTransferencia> GetByIdDocumento(TransactionManager transactionManager, System.Int32 _idDocumento)
		{
			int count = -1;
			return GetByIdDocumento(transactionManager, _idDocumento, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO key.
		///		FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdDocumento(TransactionManager transactionManager, System.Int32 _idDocumento, int start, int pageLength)
		{
			int count = -1;
			return GetByIdDocumento(transactionManager, _idDocumento, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO key.
		///		fkPatTransferenciaPatDocumento Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idDocumento"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdDocumento(System.Int32 _idDocumento, int start, int pageLength)
		{
			int count =  -1;
			return GetByIdDocumento(null, _idDocumento, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO key.
		///		fkPatTransferenciaPatDocumento Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idDocumento"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdDocumento(System.Int32 _idDocumento, int start, int pageLength,out int count)
		{
			return GetByIdDocumento(null, _idDocumento, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO key.
		///		FK_PAT_TRANSFERENCIA_PAT_DOCUMENTO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public abstract TList<PatTransferencia> GetByIdDocumento(TransactionManager transactionManager, System.Int32 _idDocumento, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS key.
		///		FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS Description: 
		/// </summary>
		/// <param name="_idItemListaPrecio"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdItemListaPrecio(System.Byte _idItemListaPrecio)
		{
			int count = -1;
			return GetByIdItemListaPrecio(_idItemListaPrecio, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS key.
		///		FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemListaPrecio"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		/// <remarks></remarks>
		public TList<PatTransferencia> GetByIdItemListaPrecio(TransactionManager transactionManager, System.Byte _idItemListaPrecio)
		{
			int count = -1;
			return GetByIdItemListaPrecio(transactionManager, _idItemListaPrecio, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS key.
		///		FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemListaPrecio"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdItemListaPrecio(TransactionManager transactionManager, System.Byte _idItemListaPrecio, int start, int pageLength)
		{
			int count = -1;
			return GetByIdItemListaPrecio(transactionManager, _idItemListaPrecio, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS key.
		///		fkPatTransferenciaPatItemListaPrecios Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idItemListaPrecio"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdItemListaPrecio(System.Byte _idItemListaPrecio, int start, int pageLength)
		{
			int count =  -1;
			return GetByIdItemListaPrecio(null, _idItemListaPrecio, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS key.
		///		fkPatTransferenciaPatItemListaPrecios Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idItemListaPrecio"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public TList<PatTransferencia> GetByIdItemListaPrecio(System.Byte _idItemListaPrecio, int start, int pageLength,out int count)
		{
			return GetByIdItemListaPrecio(null, _idItemListaPrecio, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS key.
		///		FK_PAT_TRANSFERENCIA_PAT_ITEM_LISTA_PRECIOS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idItemListaPrecio"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTransferencia objects.</returns>
		public abstract TList<PatTransferencia> GetByIdItemListaPrecio(TransactionManager transactionManager, System.Byte _idItemListaPrecio, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override PAT.Entities.PatTransferencia Get(TransactionManager transactionManager, PAT.Entities.PatTransferenciaKey key, int start, int pageLength)
		{
			return GetByIdDocumentoNumeroTransferencia(transactionManager, key.IdDocumento, key.NumeroTransferencia, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_PAT_TRANSFERENCIA index.
		/// </summary>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroTransferencia"></param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTransferencia"/> class.</returns>
		public PAT.Entities.PatTransferencia GetByIdDocumentoNumeroTransferencia(System.Int32 _idDocumento, System.Int32 _numeroTransferencia)
		{
			int count = -1;
			return GetByIdDocumentoNumeroTransferencia(null,_idDocumento, _numeroTransferencia, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TRANSFERENCIA index.
		/// </summary>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroTransferencia"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTransferencia"/> class.</returns>
		public PAT.Entities.PatTransferencia GetByIdDocumentoNumeroTransferencia(System.Int32 _idDocumento, System.Int32 _numeroTransferencia, int start, int pageLength)
		{
			int count = -1;
			return GetByIdDocumentoNumeroTransferencia(null, _idDocumento, _numeroTransferencia, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TRANSFERENCIA index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroTransferencia"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTransferencia"/> class.</returns>
		public PAT.Entities.PatTransferencia GetByIdDocumentoNumeroTransferencia(TransactionManager transactionManager, System.Int32 _idDocumento, System.Int32 _numeroTransferencia)
		{
			int count = -1;
			return GetByIdDocumentoNumeroTransferencia(transactionManager, _idDocumento, _numeroTransferencia, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TRANSFERENCIA index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroTransferencia"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTransferencia"/> class.</returns>
		public PAT.Entities.PatTransferencia GetByIdDocumentoNumeroTransferencia(TransactionManager transactionManager, System.Int32 _idDocumento, System.Int32 _numeroTransferencia, int start, int pageLength)
		{
			int count = -1;
			return GetByIdDocumentoNumeroTransferencia(transactionManager, _idDocumento, _numeroTransferencia, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TRANSFERENCIA index.
		/// </summary>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroTransferencia"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTransferencia"/> class.</returns>
		public PAT.Entities.PatTransferencia GetByIdDocumentoNumeroTransferencia(System.Int32 _idDocumento, System.Int32 _numeroTransferencia, int start, int pageLength, out int count)
		{
			return GetByIdDocumentoNumeroTransferencia(null, _idDocumento, _numeroTransferencia, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TRANSFERENCIA index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idDocumento"></param>
		/// <param name="_numeroTransferencia"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTransferencia"/> class.</returns>
		public abstract PAT.Entities.PatTransferencia GetByIdDocumentoNumeroTransferencia(TransactionManager transactionManager, System.Int32 _idDocumento, System.Int32 _numeroTransferencia, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;PatTransferencia&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;PatTransferencia&gt;"/></returns>
		public static TList<PatTransferencia> Fill(IDataReader reader, TList<PatTransferencia> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				PAT.Entities.PatTransferencia c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("PatTransferencia")
					.Append("|").Append((System.Int32)reader[((int)PatTransferenciaColumn.IdDocumento - 1)])
					.Append("|").Append((System.Int32)reader[((int)PatTransferenciaColumn.NumeroTransferencia - 1)]).ToString();
					c = EntityManager.LocateOrCreate<PatTransferencia>(
					key.ToString(), // EntityTrackingKey
					"PatTransferencia",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new PAT.Entities.PatTransferencia();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.IdDocumento = (System.Int32)reader[((int)PatTransferenciaColumn.IdDocumento - 1)];
					c.OriginalIdDocumento = c.IdDocumento;
					c.NumeroTransferencia = (System.Int32)reader[((int)PatTransferenciaColumn.NumeroTransferencia - 1)];
					c.OriginalNumeroTransferencia = c.NumeroTransferencia;
					c.FechaTransferencia = (System.DateTime)reader[((int)PatTransferenciaColumn.FechaTransferencia - 1)];
					c.Activo = (System.Boolean)reader[((int)PatTransferenciaColumn.Activo - 1)];
					c.IdCargoTransferencia = (System.Byte)reader[((int)PatTransferenciaColumn.IdCargoTransferencia - 1)];
					c.IdItemListaPrecio = (System.Byte)reader[((int)PatTransferenciaColumn.IdItemListaPrecio - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatTransferencia"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatTransferencia"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, PAT.Entities.PatTransferencia entity)
		{
			if (!reader.Read()) return;
			
			entity.IdDocumento = (System.Int32)reader[((int)PatTransferenciaColumn.IdDocumento - 1)];
			entity.OriginalIdDocumento = (System.Int32)reader["ID_DOCUMENTO"];
			entity.NumeroTransferencia = (System.Int32)reader[((int)PatTransferenciaColumn.NumeroTransferencia - 1)];
			entity.OriginalNumeroTransferencia = (System.Int32)reader["NUMERO_TRANSFERENCIA"];
			entity.FechaTransferencia = (System.DateTime)reader[((int)PatTransferenciaColumn.FechaTransferencia - 1)];
			entity.Activo = (System.Boolean)reader[((int)PatTransferenciaColumn.Activo - 1)];
			entity.IdCargoTransferencia = (System.Byte)reader[((int)PatTransferenciaColumn.IdCargoTransferencia - 1)];
			entity.IdItemListaPrecio = (System.Byte)reader[((int)PatTransferenciaColumn.IdItemListaPrecio - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatTransferencia"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatTransferencia"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, PAT.Entities.PatTransferencia entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IdDocumento = (System.Int32)dataRow["ID_DOCUMENTO"];
			entity.OriginalIdDocumento = (System.Int32)dataRow["ID_DOCUMENTO"];
			entity.NumeroTransferencia = (System.Int32)dataRow["NUMERO_TRANSFERENCIA"];
			entity.OriginalNumeroTransferencia = (System.Int32)dataRow["NUMERO_TRANSFERENCIA"];
			entity.FechaTransferencia = (System.DateTime)dataRow["FECHA_TRANSFERENCIA"];
			entity.Activo = (System.Boolean)dataRow["ACTIVO"];
			entity.IdCargoTransferencia = (System.Byte)dataRow["ID_CARGO_TRANSFERENCIA"];
			entity.IdItemListaPrecio = (System.Byte)dataRow["ID_ITEM_LISTA_PRECIO"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatTransferencia"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">PAT.Entities.PatTransferencia Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, PAT.Entities.PatTransferencia entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region IdCargoTransferenciaSource	
			if (CanDeepLoad(entity, "PatCargoOrden|IdCargoTransferenciaSource", deepLoadType, innerList) 
				&& entity.IdCargoTransferenciaSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdCargoTransferencia;
				PatCargoOrden tmpEntity = EntityManager.LocateEntity<PatCargoOrden>(EntityLocator.ConstructKeyFromPkItems(typeof(PatCargoOrden), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdCargoTransferenciaSource = tmpEntity;
				else
					entity.IdCargoTransferenciaSource = DataRepository.PatCargoOrdenProvider.GetByIdCargoOrden(transactionManager, entity.IdCargoTransferencia);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdCargoTransferenciaSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdCargoTransferenciaSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatCargoOrdenProvider.DeepLoad(transactionManager, entity.IdCargoTransferenciaSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdCargoTransferenciaSource

			#region IdDocumentoSource	
			if (CanDeepLoad(entity, "PatDocumento|IdDocumentoSource", deepLoadType, innerList) 
				&& entity.IdDocumentoSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdDocumento;
				PatDocumento tmpEntity = EntityManager.LocateEntity<PatDocumento>(EntityLocator.ConstructKeyFromPkItems(typeof(PatDocumento), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdDocumentoSource = tmpEntity;
				else
					entity.IdDocumentoSource = DataRepository.PatDocumentoProvider.GetByIdDocumento(transactionManager, entity.IdDocumento);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdDocumentoSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdDocumentoSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatDocumentoProvider.DeepLoad(transactionManager, entity.IdDocumentoSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdDocumentoSource

			#region IdItemListaPrecioSource	
			if (CanDeepLoad(entity, "PatItemListaPrecios|IdItemListaPrecioSource", deepLoadType, innerList) 
				&& entity.IdItemListaPrecioSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdItemListaPrecio;
				PatItemListaPrecios tmpEntity = EntityManager.LocateEntity<PatItemListaPrecios>(EntityLocator.ConstructKeyFromPkItems(typeof(PatItemListaPrecios), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdItemListaPrecioSource = tmpEntity;
				else
					entity.IdItemListaPrecioSource = DataRepository.PatItemListaPreciosProvider.GetByIdItemListaPrecio(transactionManager, entity.IdItemListaPrecio);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdItemListaPrecioSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdItemListaPrecioSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatItemListaPreciosProvider.DeepLoad(transactionManager, entity.IdItemListaPrecioSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdItemListaPrecioSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByIdDocumentoNumeroTransferencia methods when available
			
			#region IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatItemInventario>|IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle", deepLoadType, innerList))
			{
				entity.IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle = DataRepository.PatItemInventarioProvider.GetByIdDocumentoNumeroTransferenciaFromPatTransferenciaDetalle(transactionManager, entity.IdDocumento, entity.NumeroTransferencia);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle != null)
				{
					deepHandles.Add("IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatItemInventario >) DataRepository.PatItemInventarioProvider.DeepLoad,
						new object[] { transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region PatOrdenTrabajoTransferenciaCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatOrdenTrabajoTransferencia>|PatOrdenTrabajoTransferenciaCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatOrdenTrabajoTransferenciaCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatOrdenTrabajoTransferenciaCollection = DataRepository.PatOrdenTrabajoTransferenciaProvider.GetByIdDocumentoTransferenciaNumeroTransferencia(transactionManager, entity.IdDocumento, entity.NumeroTransferencia);

				if (deep && entity.PatOrdenTrabajoTransferenciaCollection.Count > 0)
				{
					deepHandles.Add("PatOrdenTrabajoTransferenciaCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatOrdenTrabajoTransferencia>) DataRepository.PatOrdenTrabajoTransferenciaProvider.DeepLoad,
						new object[] { transactionManager, entity.PatOrdenTrabajoTransferenciaCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region PatTransferenciaDetalleCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PatTransferenciaDetalle>|PatTransferenciaDetalleCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PatTransferenciaDetalleCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PatTransferenciaDetalleCollection = DataRepository.PatTransferenciaDetalleProvider.GetByIdDocumentoNumeroTransferencia(transactionManager, entity.IdDocumento, entity.NumeroTransferencia);

				if (deep && entity.PatTransferenciaDetalleCollection.Count > 0)
				{
					deepHandles.Add("PatTransferenciaDetalleCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PatTransferenciaDetalle>) DataRepository.PatTransferenciaDetalleProvider.DeepLoad,
						new object[] { transactionManager, entity.PatTransferenciaDetalleCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<PatOrdenTrabajo>|IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia", deepLoadType, innerList))
			{
				entity.IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia = DataRepository.PatOrdenTrabajoProvider.GetByIdDocumentoTransferenciaNumeroTransferenciaFromPatOrdenTrabajoTransferencia(transactionManager, entity.IdDocumento, entity.NumeroTransferencia);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia != null)
				{
					deepHandles.Add("IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< PatOrdenTrabajo >) DataRepository.PatOrdenTrabajoProvider.DeepLoad,
						new object[] { transactionManager, entity.IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the PAT.Entities.PatTransferencia object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">PAT.Entities.PatTransferencia instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">PAT.Entities.PatTransferencia Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, PAT.Entities.PatTransferencia entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region IdCargoTransferenciaSource
			if (CanDeepSave(entity, "PatCargoOrden|IdCargoTransferenciaSource", deepSaveType, innerList) 
				&& entity.IdCargoTransferenciaSource != null)
			{
				DataRepository.PatCargoOrdenProvider.Save(transactionManager, entity.IdCargoTransferenciaSource);
				entity.IdCargoTransferencia = entity.IdCargoTransferenciaSource.IdCargoOrden;
			}
			#endregion 
			
			#region IdDocumentoSource
			if (CanDeepSave(entity, "PatDocumento|IdDocumentoSource", deepSaveType, innerList) 
				&& entity.IdDocumentoSource != null)
			{
				DataRepository.PatDocumentoProvider.Save(transactionManager, entity.IdDocumentoSource);
				entity.IdDocumento = entity.IdDocumentoSource.IdDocumento;
			}
			#endregion 
			
			#region IdItemListaPrecioSource
			if (CanDeepSave(entity, "PatItemListaPrecios|IdItemListaPrecioSource", deepSaveType, innerList) 
				&& entity.IdItemListaPrecioSource != null)
			{
				DataRepository.PatItemListaPreciosProvider.Save(transactionManager, entity.IdItemListaPrecioSource);
				entity.IdItemListaPrecio = entity.IdItemListaPrecioSource.IdItemListaPrecio;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();

			#region IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle>
			if (CanDeepSave(entity.IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle, "List<PatItemInventario>|IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle", deepSaveType, innerList))
			{
				if (entity.IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle.Count > 0 || entity.IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle.DeletedItems.Count > 0)
				{
					DataRepository.PatItemInventarioProvider.Save(transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle); 
					deepHandles.Add("IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatItemInventario>) DataRepository.PatItemInventarioProvider.DeepSave,
						new object[] { transactionManager, entity.IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia>
			if (CanDeepSave(entity.IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia, "List<PatOrdenTrabajo>|IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia", deepSaveType, innerList))
			{
				if (entity.IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia.Count > 0 || entity.IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia.DeletedItems.Count > 0)
				{
					DataRepository.PatOrdenTrabajoProvider.Save(transactionManager, entity.IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia); 
					deepHandles.Add("IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<PatOrdenTrabajo>) DataRepository.PatOrdenTrabajoProvider.DeepSave,
						new object[] { transactionManager, entity.IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 
	
			#region List<PatOrdenTrabajoTransferencia>
				if (CanDeepSave(entity.PatOrdenTrabajoTransferenciaCollection, "List<PatOrdenTrabajoTransferencia>|PatOrdenTrabajoTransferenciaCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatOrdenTrabajoTransferencia child in entity.PatOrdenTrabajoTransferenciaCollection)
					{
						if(child.IdDocumentoTransferenciaNumeroTransferenciaSource != null)
						{
								child.IdDocumentoTransferencia = child.IdDocumentoTransferenciaNumeroTransferenciaSource.IdDocumento;
								child.NumeroTransferencia = child.IdDocumentoTransferenciaNumeroTransferenciaSource.NumeroTransferencia;
						}

						if(child.IdDocumentoOrdenNumeroOrdenSource != null)
						{
								child.IdDocumentoOrden = child.IdDocumentoOrdenNumeroOrdenSource.IdDocumento;
								child.NumeroOrden = child.IdDocumentoOrdenNumeroOrdenSource.NumeroOrden;
						}

					}

					if (entity.PatOrdenTrabajoTransferenciaCollection.Count > 0 || entity.PatOrdenTrabajoTransferenciaCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatOrdenTrabajoTransferenciaProvider.Save(transactionManager, entity.PatOrdenTrabajoTransferenciaCollection);
						
						deepHandles.Add("PatOrdenTrabajoTransferenciaCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatOrdenTrabajoTransferencia >) DataRepository.PatOrdenTrabajoTransferenciaProvider.DeepSave,
							new object[] { transactionManager, entity.PatOrdenTrabajoTransferenciaCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PatTransferenciaDetalle>
				if (CanDeepSave(entity.PatTransferenciaDetalleCollection, "List<PatTransferenciaDetalle>|PatTransferenciaDetalleCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PatTransferenciaDetalle child in entity.PatTransferenciaDetalleCollection)
					{
						if(child.IdDocumentoNumeroTransferenciaSource != null)
						{
								child.IdDocumento = child.IdDocumentoNumeroTransferenciaSource.IdDocumento;
								child.NumeroTransferencia = child.IdDocumentoNumeroTransferenciaSource.NumeroTransferencia;
						}

						if(child.IdItemInventarioSource != null)
						{
								child.IdItemInventario = child.IdItemInventarioSource.IdItemInventario;
						}

					}

					if (entity.PatTransferenciaDetalleCollection.Count > 0 || entity.PatTransferenciaDetalleCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PatTransferenciaDetalleProvider.Save(transactionManager, entity.PatTransferenciaDetalleCollection);
						
						deepHandles.Add("PatTransferenciaDetalleCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PatTransferenciaDetalle >) DataRepository.PatTransferenciaDetalleProvider.DeepSave,
							new object[] { transactionManager, entity.PatTransferenciaDetalleCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region PatTransferenciaChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>PAT.Entities.PatTransferencia</c>
	///</summary>
	public enum PatTransferenciaChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>PatCargoOrden</c> at IdCargoTransferenciaSource
		///</summary>
		[ChildEntityType(typeof(PatCargoOrden))]
		PatCargoOrden,
			
		///<summary>
		/// Composite Property for <c>PatDocumento</c> at IdDocumentoSource
		///</summary>
		[ChildEntityType(typeof(PatDocumento))]
		PatDocumento,
			
		///<summary>
		/// Composite Property for <c>PatItemListaPrecios</c> at IdItemListaPrecioSource
		///</summary>
		[ChildEntityType(typeof(PatItemListaPrecios))]
		PatItemListaPrecios,
	
		///<summary>
		/// Collection of <c>PatTransferencia</c> as ManyToMany for PatItemInventarioCollection_From_PatTransferenciaDetalle
		///</summary>
		[ChildEntityType(typeof(TList<PatItemInventario>))]
		IdItemInventarioPatItemInventarioCollection_From_PatTransferenciaDetalle,

		///<summary>
		/// Collection of <c>PatTransferencia</c> as OneToMany for PatOrdenTrabajoTransferenciaCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatOrdenTrabajoTransferencia>))]
		PatOrdenTrabajoTransferenciaCollection,

		///<summary>
		/// Collection of <c>PatTransferencia</c> as OneToMany for PatTransferenciaDetalleCollection
		///</summary>
		[ChildEntityType(typeof(TList<PatTransferenciaDetalle>))]
		PatTransferenciaDetalleCollection,

		///<summary>
		/// Collection of <c>PatTransferencia</c> as ManyToMany for PatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia
		///</summary>
		[ChildEntityType(typeof(TList<PatOrdenTrabajo>))]
		IdDocumentoOrdenNumeroOrdenPatOrdenTrabajoCollection_From_PatOrdenTrabajoTransferencia,
	}
	
	#endregion PatTransferenciaChildEntityTypes
	
	#region PatTransferenciaFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;PatTransferenciaColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatTransferencia"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatTransferenciaFilterBuilder : SqlFilterBuilder<PatTransferenciaColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatTransferenciaFilterBuilder class.
		/// </summary>
		public PatTransferenciaFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatTransferenciaFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatTransferenciaFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatTransferenciaFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatTransferenciaFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatTransferenciaFilterBuilder
	
	#region PatTransferenciaParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;PatTransferenciaColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatTransferencia"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatTransferenciaParameterBuilder : ParameterizedSqlFilterBuilder<PatTransferenciaColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatTransferenciaParameterBuilder class.
		/// </summary>
		public PatTransferenciaParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatTransferenciaParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatTransferenciaParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatTransferenciaParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatTransferenciaParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatTransferenciaParameterBuilder
	
	#region PatTransferenciaSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;PatTransferenciaColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatTransferencia"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class PatTransferenciaSortBuilder : SqlSortBuilder<PatTransferenciaColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatTransferenciaSqlSortBuilder class.
		/// </summary>
		public PatTransferenciaSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion PatTransferenciaSortBuilder
	
} // end namespace
